<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>后台管理员管理</title>
	<link rel="stylesheet" href="css/reset.css" />
	<link rel="stylesheet" href="css/content.css" />
	<script type="text/javascript" src="js/jquery-2.1.1.js"></script>
	<script type="text/javascript">
	
			var nowpage;
			var currpage = '${sessionScope.adminpage.currentpage}';
			var total = '${sessionScope.adminpage.totalpage}';
	$(function(){
		$("#nextpage").click(function(){
			//alert(currpage);
			//alert(total);
					if(currpage==total){
						return;
					}else{
					//alert(parseInt(currpage));
						currpage=parseInt(currpage)+1;
					}
			//alert(parseInt(currpage));
			page(currpage);
			$("#nowpage").text(currpage);
		});	
		
		$("#prepage").click(function(){
			//alert(currpage);
			//alert(total);
					if(currpage==1){
					//alert(parseInt(currpage));
						return;
					}else{
						currpage=parseInt(currpage)-1;
					
					}
			//alert(parseInt(currpage));
			page(currpage);
			$("#nowpage").text(currpage);
		});	
		
		$("#skip").click(function(){
			var pg = $("#pagecurr").val();
			page(pg);
			$("#nowpage").text(pg);
		});
		
		$("#firstpage").click(function(){
			page(1);
			$("#nowpage").text(1);
		});
	
	function page(pg){
		//alert(pg);
			$.ajax({
				type:'post',
				url:'${pageContext.request.contextPath }/ajax/pagequeryadminajax',
				data:{
					curr:pg
				},
				success:function(response,status,xhr){
					var jsonobj = eval('('+response+')');
					var lengthlist = jsonobj.adminlist.length;
		    		//alert(lengthlist);
					$("#tb").empty();
					
		    		var tbobj = document.getElementById("tb");
		    		for(var i=0;i<lengthlist;i++){
		    		    var optTr = document.createElement("tr");
		    		    var optObj1 = document.createElement("td");
		    		    var optObj2 = document.createElement("td");
		    		    var optObj3 = document.createElement("td");
		    		    optObj1.innerHTML=jsonobj.adminlist[i].adminid;
		    		    optObj2.innerHTML=jsonobj.adminlist[i].adminname;
		    		    optObj3.innerHTML="系统管理员";
		    		    optTr.appendChild(optObj1);
		    		    optTr.appendChild(optObj2);
		    		    optTr.appendChild(optObj3);
		    		    tbobj.appendChild(optTr);
    				}
			
				}
			});		
	}
	
	
	});
	//function skip(){
	//var pagecurrval = document.getElementById("pagecurr").value;
	//skippage(pagecurrval);
	//}
	

	
	
	
	//}
	</script>
</head>
<body marginwidth="0" marginheight="0">
	<div class="container">
		<div class="public-nav">您当前的位置：<a>管理首页</a>><a href="">管理员管理</a></div>
		<div class="public-content">
			<div class="public-content-header">
				<h3>管理员列表</h3>
			</div>
			<div class="public-content-cont">
				<table class="public-cont-table">
					<tr>
						<th style="width:20%">编号</th>
						<th style="width:20%">管理员名称</th>
						<th style="width:20%">权限角色</th>
					</tr>
					<tbody id="tb">
					<c:forEach items="${sessionScope.adminpage.adminlist}" var="admin" varStatus="a">
					<tr id="tbtr">
						<td id="adminid">${admin.adminid}</td>
						<td id="adminname">${admin.adminname}</td>
						<td>系统管理员</td>
					</tr>
					</c:forEach>
					</tbody>
				</table>
				<div class="page">
						<a id="firstpage" style="cursor:pointer;">首页</a>
						<a id="prepage" style="cursor:pointer;">上一页</a>
						<a id="nextpage" style="cursor:pointer;">下一页</a>
						第<span style="color:red;font-weight:600" id="nowpage">1</span>页
						共<span style="color:red;font-weight:600">${sessionScope.adminpage.totalpage}</span>页
						<input id="pagecurr" type="text" class="page-input">
						<input type="submit" class="page-btn" value="跳转" id="skip">
				</div>
			</div>
		</div>
	</div>
</body>
</html>